//
//  JumpToHomeMessage.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/3/12.
//  
  

#import "JumpToHomeMessage.h"
#import <YYKit/YYKit.h>


@implementation JumpToHomeMessage

- (NSString *)name {
    return @"lemonadeW";
}
- (instancetype)initWithController:(UIViewController *)controller {
    if (self = [super init]) {
        self.controller = controller;
    }
    return self;
}
- (void)handleMessage:(WKScriptMessage *)message {
    if ([message.name isEqualToString:self.name]) {
        UITabBarController *tabbarCtrl = (UITabBarController *)UIApplication.sharedApplication.keyWindow.rootViewController;
        if (![tabbarCtrl isKindOfClass:UITabBarController.class]) {
            return;
        }
        [_controller.navigationController popToRootViewControllerAnimated:YES];
        tabbarCtrl.selectedIndex = 0;
    }
}

@end
